import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { Language } from "../../../../../extend/language/Language";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { SWrestleBattle } from "../../../../../Message/Public/SWrestleBattle";
import { PlayerUtil } from "../../common/util/PlayerUtil";
import { GButton } from "../../../../../com/mui/controls/GButton";
//class WrestleBattleCellRenderer
    
    export  class WrestleBattleCellRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            var loc1=GlobalStyle.textFormat1;
            loc1.align = flash.text.TextFormatAlign.CENTER;
            var loc2=GlobalStyle.textFormatOrange;
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._tfName1 = ObjCreate.createTextField("", 0, 14, 180, 20, this, loc1);
            this._tfScore1 = ObjCreate.createTextField("", 180, 14, 60, 20, this, loc1);
            this._bmpVS = ObjCreate.createBitmap(ImagesConst.ArenaVS, 240, 2, this);
            this._tfName2 = ObjCreate.createTextField("", 285, 14, 180, 20, this, loc1);
            this._tfScore2 = ObjCreate.createTextField("", 465, 14, 60, 20, this, loc1);
            this._btnLook = ObjCreate.createGButton(Language.getString(44420), 540, 7, 48, 28, this, "LinkButtonWhite");
            this._btnLook.addEventListener(flash.events.MouseEvent.CLICK, this.onClickLook);
            ObjCreate.createBg(3, 40, 600, 2, this, "SplitLine");
            return;
        }

        /* internal  */onClickLook(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._wrestleBattle) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.WrestleLookBattle, this._wrestleBattle.wrestleId));
            }
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            if (typeof arg1 === "swrestlebattle") 
            {
                this._wrestleBattle = arg1 as SWrestleBattle;
                this.updateView();
            }
            return;
        }

        /* internal  */updateView(): void
        {
            this._tfName1.text = PlayerUtil.getProxyAndNameByEntityIdAndName(this._wrestleBattle.playerOne.entityId, this._wrestleBattle.playerOne.name);
            this._tfScore1.text = this._wrestleBattle.playerOne.mark.toString();
            this._tfName2.text = PlayerUtil.getProxyAndNameByEntityIdAndName(this._wrestleBattle.playerTwo.entityId, this._wrestleBattle.playerTwo.name);
            this._tfScore2.text = this._wrestleBattle.playerTwo.mark.toString();
            return;
        }

        /* internal */ /* var */_tfName1: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfScore1: Object /* flash.text.TextField */;

        /* internal */ /* var */_bmpVS: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfName2: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfScore2: Object /* flash.text.TextField */;

        /* internal */ /* var */_btnLook: GButton;

        /* internal */ /* var */_wrestleBattle: SWrestleBattle;
    }
